﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SHKF.B2C.BaseHosted;
using SHKF.B2C.Hosted;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;

namespace SHKF.B2C.WebService.Controllers
{
    [Route("[controller]")]
    [ApiController]
    public class Base2Controller : BaseController
    {
        public Base2Controller(ILogger<Base2Controller> logger) : base(logger)
        {

        }

        public string UserName
        {
            get
            {
                Claim claim = this.User
                    .Claims.Where(oo => oo.Type == "UserName")
                    .FirstOrDefault();
                if (claim != null)
                {
                    return claim.Value;
                }
                return "";
            }
        }

        public int SN
        {
            get
            {
                Claim claim = this.User
                    .Claims.Where(oo => oo.Type == "SN")
                    .FirstOrDefault();
                if (claim != null)
                {
                    return int.Parse(claim.Value);
                }

                return -1;
            }
        }

        public int ShopSN
        {
            get
            {
                Claim claim = this.User
                    .Claims.Where(oo => oo.Type == "ShopSN")
                    .FirstOrDefault();
                if (claim != null)
                {
                    return int.Parse(claim.Value);
                }

                return -1;
            }
        }

        public int CompanySN
        {
            get
            {
                Claim claim = this.User
                    .Claims.Where(oo => oo.Type == "CompanySN")
                    .FirstOrDefault();
                if (claim != null)
                {
                    return int.Parse(claim.Value);
                }

                return -1;
            }
        }

    }

}
